package mid;

import java.util.Arrays;

public class a462_最少移动次数使数组元素相等II {
    public int minMoves2(int[] nums) {
        Arrays.sort(nums);
        int N=nums.length/2;
        int count=0;
        for(int i=0;i<nums.length;i++){
            count+=Math.abs(nums[N]-nums[i]);
        }
        return count;
    }
}
